package demo_code;
//类遵守单一职责原则
class Ludi {
    public void run(String vehicle) {
        System.out.println(vehicle + "在公路运行");
    }
}
class FeiX {
    public void run(String vehicle) {
        System.out.println(vehicle + "在天空运行");
    }
}
class ShuiZ {
    public void run(String vehicle) {
        System.out.println(vehicle + "在水中运行");
    }
}
//方法遵守单一职责原则
class Yund{
    public void runLu(String vehicle) {
        System.out.println(vehicle + "在公路运行");
    }

    public void runTian(String vehicle) {
        System.out.println(vehicle + "在天空运行");
    }

    public void runShui(String vehicle) {
        System.out.println(vehicle + "在水中运行");
    }
}

public class Vehicle_2 {
    public static void main(String[] args) {
        //1.0
        System.out.println("********类遵守单一职责原则*********");
        Ludi ludi = new Ludi();
        ludi.run("摩托车");
        ludi.run("汽车");

        FeiX feix = new FeiX();
        feix.run("飞机");

        ShuiZ shuiz = new ShuiZ();
        shuiz.run("轮船");
    //2.0
        System.out.println("******方法遵守单一职责原则********");
        Yund yund = new Yund();
        yund.runLu("机动车");
        yund.runTian("直升机");
        yund.runShui("潜水艇");

    }
}
